﻿//
// Created by wellwei on 2023/12/5.
//

#include "Book.h"
#include <iostream>
#include <iomanip>

Book::Book() // 默认构造函数
{
	name = "";
	author = "";
	ISBN = "";
	price = 0;
	publisher = "";
	publishDate = "";
	barcode = "";
	classification = 0;
	location = "";
	total = 0;
	available = 0;
}

Book::Book(std::string name, std::string author, std::string ISBN, double price,
	std::string publisher, std::string publishDate, std::string barcode, int classification,
	std::string location, int total, int available) // 构造函数
{
	this->name = name;
	this->author = author;
	this->ISBN = ISBN;
	this->price = price;
	this->publisher = publisher;
	this->publishDate = publishDate;
	this->barcode = barcode;
	this->classification = classification;
	this->location = location;
	this->total = total;
	this->available = available;
}

// 以下为各个属性的 get 和 set 函数

void Book::setName(std::string name) { this->name = name; }

void Book::setAuthor(std::string author) { this->author = author; }

void Book::setISBN(std::string ISBN) { this->ISBN = ISBN; }

void Book::setPrice(double price) { this->price = price; }

void Book::setPublisher(std::string publisher) { this->publisher = publisher; }

void Book::setPublishDate(std::string publishDate) { this->publishDate = publishDate; }

void Book::setBarcode(std::string barcode) { this->barcode = barcode; }

void Book::setClassification(int classification) { this->classification = classification; }

void Book::setLocation(std::string location) { this->location = location; }

void Book::setTotal(int total) { this->total = total; }

void Book::setAvailable(int available) { this->available = available; }

void Book::setIndex(int index) { this->index = index; }


std::string Book::getName() { return name; }

std::string Book::getAuthor() { return author; }

std::string Book::getISBN() { return ISBN; }

double Book::getPrice() { return price; }

std::string Book::getPublisher() { return publisher; }

std::string Book::getPublishDate() { return publishDate; }

std::string Book::getBarcode() { return barcode; }

int Book::getClassification() { return classification; }

std::string Book::getLocation() { return location; }

int Book::getTotal() { return total; }

int Book::getAvailable() { return available; }

int Book::getIndex() { return index; }

void Book::showInfo() { // 显示图书信息
	std::cout << std::setfill(' ') << std::setw(10) << std::left << barcode
		<< std::setfill(' ') << std::setw(16) << std::left << name
		<< std::setfill(' ') << std::setw(18) << std::left << author
		<< std::setfill(' ') << std::setw(15) << std::left << ISBN
		<< std::setfill(' ') << std::setw(8) << std::left << price
		<< std::setfill(' ') << std::setw(16) << std::left << publisher
		<< std::setfill(' ') << std::setw(20) << std::left << publishDate
		<< std::setfill(' ') << std::setw(10) << std::left << classification
		<< std::setfill(' ') << std::setw(10) << std::left << location
		<< std::setfill(' ') << std::setw(10) << std::left << total
		<< std::setfill(' ') << std::setw(10) << std::left << available
		<< std::endl;
}

void Book::showInfo1() { // 显示图书信息
	std::cout << std::setfill(' ') << std::setw(10) << std::left << barcode
		<< std::setfill(' ') << std::setw(16) << std::left << name
		<< std::setfill(' ') << std::setw(18) << std::left << author
		<< std::setfill(' ') << std::setw(15) << std::left << ISBN
		<< std::setfill(' ') << std::setw(8) << std::left << price
		<< std::setfill(' ') << std::setw(16) << std::left << publisher
		<< std::setfill(' ') << std::setw(20) << std::left << publishDate
		<< std::setfill(' ') << std::setw(10) << std::left << classification
		<< std::setfill(' ') << std::setw(10) << std::left << location
		<< std::setfill(' ') << std::setw(10) << std::left << total
		<< std::endl;
}